<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<html:hidden name="transaction" property="totalPriceAndTaxes" styleId="totalPriceWithTaxesID"/>
<html:hidden name="transaction" property="totalTaxes"/>
<html:hidden name="transaction" property="totalPrice" styleId="totalPriceID"/>
<html:hidden name="transaction" property="customerBean.id"/>

<html:form action="/payment" styleId="paymentId">
    <html:hidden name="transaction" property="totalPriceAndTaxes"/>
    <html:hidden name="transaction" property="totalTaxes"/>
    <html:hidden name="transaction" property="totalPrice" styleId="totalPriceID"/>
    <html:hidden name="transaction" property="customerBean.id"/>
    <table>
        <tr>
            <td>
                <bean:message key="payment.table.price"/>
            </td>
            <td>
                <bean:write name='transaction' property='totalPrice' formatKey="usd.money.format"/>
            </td>
        </tr>
        <tr>
            <td><bean:message key="payment.table.taxes"/></td>
            <td><bean:write name="transaction" property="totalTaxes" formatKey="usd.money.format"/></td>
        </tr>
        <tr>
            <td><bean:message key="payment.table.discount"/></td>
            <td><html:text property="discount"/>%</td>
        </tr>
        <tr>
            <td><bean:message key="payment.table.total"/></td>
            <td><bean:write name="transaction" property="totalPriceAndTaxes" formatKey="usd.money.format"/></td>
        </tr>

        <tr>
            <td><bean:message key="payment.table.cash"/></td>
            <td>
                <html:text property="amount"/>
                <logic:equal value="5" name="paymentForm" property="type">
                    <html:img page="/images/calc1b.gif" onclick="XT.doAjaxAction('calculateChange', this)"/>
                </logic:equal>
            </td>
        </tr>
        <logic:equal value="5" name="paymentForm" property="type">
            <tr>
                <td><bean:message key="payment.table.cash.change"/></td>
                <td id="cachChange"/>
            </tr>
        </logic:equal>
        <logic:equal value="6" name="paymentForm" property="type">
            <tr>
                <td><bean:message key="payment.table.giftcard"/></td>
                <td>
                    <input type="text" name="giftcard" id="giftcardNumber"/>
                    <html:img page="/images/schdule_20.gif" onclick="XT.doAjaxAction('getGiftcardAmount', this)"/>
                </td>
            </tr>
            <tr>
                <td><bean:message key="payment.table.giftcard.amount"/></td>
                <td id="giftcardAmount"/>
            </tr>
        </logic:equal>
    </table>
    <html:checkbox property="checkPayment" styleId="secondPaymentCheckbox"
                   onclick="XT.doAjaxAction('getSecondPayment', this, {checked: this.checked, totalPrice : $('totalPriceWithTaxesID').value});">
        <bean:message key="payment.split.method.payment"/>
    </html:checkbox>
    <div id="secondPaymentMethodID"></div>
    <table>
        <tr>
            <td id="submitPaymentID">
                <html:button property="submittedValue" onclick="XT.doAjaxAction('validatePaymentForm', this);">
                    <bean:message key="payment.validate.button"/>
                </html:button>
            </td>
        </tr>
    </table>
    <div id="validatePaymentMethodID"></div>
</html:form>
